//浏览器打开时执行的函数
window.onload=function(){
	Weather_Time();
	sec_resize();
}
//根据当前日期变换时间图片
var NowDate = new Date();
var WeekDay = new Array("sunday","monday","tuesday","wendesday","thursday","friday","saturday");
var Month   = new Array("month1","month2","month3","month4","month5","month6","month7","month8","month9","month10","month11","month12");
var DateTime= new Array("0","1","2","3","4","5","6","7","8","9");
var Cur_Time= new Array("earlymoning","morning","lunchtime","afternoon","evening","nighttime")
function Weather_Time(){
	//星期
	document.getElementById("Week").src="img/WeekDay/"+WeekDay[NowDate.getDay()]+".png";
	//月份
	document.getElementById("Month").src="img/Month/"+Month[NowDate.getMonth()]+".png";
	//日期
	document.getElementById("Date1").src="img/Date/"+DateTime[parseInt(NowDate.getDate()/10)]+".png";
	document.getElementById("Date2").src="img/Date/"+DateTime[NowDate.getDate()%10]+".png";
	//时间
	var time = NowDate.getHours();
	if(time>=3&&time<=6){
		document.getElementById("Time").src="img/Time/"+Cur_Time[0]+".png";
	}else if(time<=11){
		document.getElementById("Time").src="img/Time/"+Cur_Time[1]+".png";
	}else if(time<=14){
		document.getElementById("Time").src="img/Time/"+Cur_Time[2]+".png";
	}else if(time<=18){
		document.getElementById("Time").src="img/Time/"+Cur_Time[3]+".png";
	}else if(time<=22){
		document.getElementById("Time").src="img/Time/"+Cur_Time[4]+".png";
	}else{
		document.getElementById("Time").src="img/Time/"+Cur_Time[5]+".png";
	}
}
//导航栏
$(document).ready(function() {  
	$("#div1Link").click(function() {  
		$("html, body").animate({  
			scrollTop: $(".section_one").offset().top }, {duration: 500,easing: "swing"});  
		return false;  
	});  
	$("#div2Link").click(function() {  
		$("html, body").animate({  
			scrollTop: $(".section_two").offset().top }, {duration: 500,easing: "swing"});  
		return false;  
	});  
	$("#div3Link").click(function() {  
		$("html, body").animate({  
			scrollTop: $(".section_three").offset().top }, {duration: 500,easing: "swing"});  
		return false;  
	});  
	$("#top").click(function() {  
		$("html, body").animate({  
			scrollTop: $("body").offset().top }, {duration: 500,easing: "swing"});  
		return false;  
	});  
});  
//侧栏
$(document).ready(function(){
	var left_height = $(".wrapper .navbar2").offset().top;
	var top_height = $(".wrapper .navbar2").offset().top + $(".wrapper .navbar2").height();
	$(window).scroll(function(){
		var this_scrollTop = $(this).scrollTop();
		if(this_scrollTop > left_height ){
			$(".wrapper .left_nav").css({'top':"40%"});
			$(".wrapper .left_nav #top").show();
		}else{
			$(".wrapper .left_nav").css({'top':top_height});
			$(".wrapper .left_nav #top").hide();
		}
	});
});
//自适应
$(document).ready(function(){
	$(window).resize(function() {
		sec_resize();
	});
});
function sec_resize(){
	x=$(".header").width();
	if(x>800){
		$("nav").show();
		$(".navbar2").show();
		$(".navbar3").hide();
		$("#Time").show();
		$(".weather img").css({'height':x*0.07});
		$(".weather > img:nth-child(2),.weather > img:nth-child(3)").height(x*0.035);
		y2=$(".header").width();
		y3=$(".navbar").width();
		$(".header").height(y2*0.07);
		$("ul .navbar").css({'font-size':y2*0.015,'height':y3*0.2});
		//section_one
		x1=$(".section_one").width();
		$(".section_one").height(x1*0.7);
		//section_two
		x2=$(".section_two").width();
		$(".section_two").height(x2*0.64);
		//section_three
		x3=$(".section_three").width();
		$(".section_three").height(x3*0.85);
		//various height
		h1=$(".section_one").height();
		h2=$(".section_two").height();
		h3=$(".section_three").height();
		h4=$(".navbar2").height();
		$(".section_one .p1").css({'width':x1*0.4,'marginTop':x1*0.37,'marginLeft':x1*0.16,'font-size':x1*0.02});
		$(".section_one .picture_wrapper1").css({'width':x1*0.7,'height':x1*0.3,'marginTop':x1*0.02,'marginLeft':x1*0.1});
		$(".picture_wrapper1 a").css({'width':x1*0.7*0.4});
		$(".picture_wrapper1 a .picture_one").css({'height':x1*0.7*0.4*0.8});
		$(".picture_wrapper1 a .picture_two").css({'height':x1*0.7*0.4*0.8,'marginLeft':x1*0.7*0.4*0.02});
		$(".section_two .p2").css({'width':x2*0.35,'marginTop':x2*0.25,'marginRight':x2*0.17,'font-size':x2*0.02});
		$(".section_two .picture_wrapper2").css({'width':x2*0.7,'height':x2*0.3,'marginTop':x2*0.02,'marginLeft':x2*0.1});
		$(".picture_wrapper2 a").css({'width':x2*0.7*0.4});
		$(".picture_wrapper2 a .picture_one").css({'height':x2*0.7*0.4*0.8});
		$(".picture_wrapper2 a .picture_two").css({'height':x2*0.7*0.4*0.8,'marginLeft':x2*0.7*0.4*0.02});
		$(".section_three .p3").css({'width':x3*0.5,'marginTop':x3*0.2,'marginRight':x3*0.17,'font-size':x3*0.02});
		$(".section_three .picture_wrapper3").css({'width':x3,'height':x3*0.4});
		$(".picture_wrapper3 a").css({'width':x3*0.7*0.33});
		$(".picture_wrapper3 a .picture_one").css({'height':x3*0.7*0.47});
		$(".picture_wrapper3 a .picture_two").css({'height':x3*0.7*0.47,'marginLeft':x3*0.7*0.4*0.005});
		$(".picture_wrapper3 a .picture_three").css({'height':x3*0.7*0.5,'marginLeft':x3*0.7*0.4*0.005});
		$(".picture_wrapper3 a .picture_four").css({'height':x3*0.7*0.56,'marginLeft':x3*0.7*0.4*0.005});
		//wrapper
		$(".wrapper").height((h1+h2+h3+h4)*1.05);
	}else{
		$("nav").hide();
		$(".navbar2").hide();
		$(".navbar3").show();
		$("#Time").hide();
		//头尾
		y2=$(".header").width();
		$(".header").height(y2*0.12);
		$(".footer").css({'font-size':y2*0.015});
		$(".weather img").css({'height':y2*0.1});
		$(".weather > img:nth-child(2),.weather > img:nth-child(3)").height(y2*0.05);
		x1=$(".section_one").width();
		$(".section_one").height(x1*0.62);
		$(".section_one .p1_bak").css({'font-size':x1*0.05});
		$(".section_one .picture_wrapper1").css({'width':x1*0.7,'height':x1*0.3,'marginTop':x1*0.02,'marginLeft':x1*0.1});
		$(".picture_wrapper1 a").css({'width':x1*0.7*0.4});
		$(".picture_wrapper1 a .picture_one").css({'height':x1*0.7*0.4});
		$(".picture_wrapper1 a .picture_two").css({'height':x1*0.7*0.4,'marginLeft':x1*0.7*0.4*0.4});
		//section_two
		x2=$(".section_two").width();
		$(".section_two").height(x2*0.56);
		$(".section_two .p2_bak").css({'font-size':x1*0.05});
		$(".section_two .picture_wrapper2").css({'width':x2*0.7,'height':x2*0.3,'marginTop':x2*0.02,'marginLeft':x2*0.1});
		$(".picture_wrapper2 a").css({'width':x2*0.7*0.4});
		$(".picture_wrapper2 a .picture_one").css({'height':x2*0.7*0.4});
		$(".picture_wrapper2 a .picture_two").css({'height':x2*0.7*0.4,'marginLeft':x2*0.7*0.4*0.4});
		//section_three
		x3=$(".section_three").width();
		$(".section_three").height(x3*0.77);
		$(".section_three .p3_bak").css({'font-size':x1*0.05});
		$(".section_three .picture_wrapper3").css({'width':x3,'height':x3*0.4,'marginTop':x2*0.02});
		$(".picture_wrapper3 a").css({'width':x3*0.7*0.33});
		$(".picture_wrapper3 a .picture_one").css({'height':x3*0.7*0.47});
		$(".picture_wrapper3 a .picture_two").css({'height':x3*0.7*0.47,'marginLeft':x3*0.7*0.4*0.01});
		$(".picture_wrapper3 a .picture_three").css({'height':x3*0.7*0.47,'marginLeft':x3*0.7*0.4*0.01});
		$(".picture_wrapper3 a .picture_four").css({'height':x3*0.7*0.47,'marginLeft':x3*0.7*0.4*0.01});
		h1=$('.navbar3').height();
		h2=$('.section_one').height();
		h3=$('.section_two').height();
		h4=$('.section_three').height();
		$(".wrapper").height((h1+h2+h3+h4)*1.2);
	}
}